import { RankBaseItem } from "./RankBaseItem";
import { TToplist } from "../../../../Message/Db/Tables/TToplist";
import { GTextFormat } from "../../../common/GTextFormat";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { EVIPType } from "../../../../Message/Public/EVIPType";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { EToplistType } from "../../../../Message/Public/EToplistType";
import { ESex } from "../../../../Message/Public/ESex";
import { Language } from "../../../../extend/language/Language";
import { CareerConfig } from "../../resource/CareerConfig";
import { ColorConfig } from "../../resource/ColorConfig";
import { GameDefConfig } from "../../resource/GameDefConfig";
type int = number;
//class PlayerRankItem
    
    export  class PlayerRankItem extends RankBaseItem
    {
        constructor(arg1: TToplist=null)
        {
            super();
            this.init();
            mouseChildren = false;
            return;
        }

        /* internal  */init(): void
        {
            this._tf = new GTextFormat("", 12, 11661311, false, false, false, null, null, flash.text.TextFormatAlign.CENTER);
            this._rankTxt = this.createTextField("", 0, 0, 30, 33, this._tf);
            this._nameTxt = this.createTextField("", 50, 0, 100, 33, this._tf);
            this._sexTxt = this.createTextField("", 150, 0, 40, 33, this._tf);
            this._careerTxt = this.createTextField("", 190, 0, 40, 33, this._tf);
            this._guildTxt = this.createTextField("", 220, 0, 100, 33, this._tf);
            this._campTxt = this.createTextField("", 305, 0, 40, 33, this._tf);
            this._campTxt.autoSize = "left";
            this._attributeTxt = this.createTextField("", 350, 0, 50, 33, this._tf);
            this._rangeTxt = this.createTextField("", 375, 0, 120, 33, this._tf);
            this._bitmap = new Object /* flash.display.Bitmap */();
            this._vipBitmap = new Object /* flash.display.Bitmap */();
            var loc1=ObjCreate.createBg(0, 25, 460, 2, this, ImagesConst.SplitLine);
            return;
        }

        /* internal  */createTextField(arg1: string, arg2: int, arg3: int, arg4: int, arg5: int, arg6: Object /* flash.text.TextFormat */): Object /* flash.text.TextField */
        {
            var loc1=null;
            (loc1 = new Object /* flash.text.TextField */()).text = arg1;
            loc1.x = arg2;
            loc1.y = arg3;
            loc1.width = arg4;
            loc1.height = arg5;
            loc1.selectable = false;
            loc1.defaultTextFormat = arg6;
            addChild(loc1);
            return loc1;
        }

        public updateItem(arg1: TToplist, arg2: int): void
        {
            var loc11=null;
            var loc13=0;
            if (arg1 == null) 
            {
                this._rankTxt.text = "";
                this._nameTxt.text = "";
                this._sexTxt.text = "";
                this._careerTxt.text = "";
                this._campTxt.text = "";
                this._guildTxt.text = "";
                this._attributeTxt.text = "";
                this._rangeTxt.text = "";
                _sEntityId = null;
                _sMiniPlayer = null;
                if (this._bitmap.parent) 
                {
                    removeChild(this._bitmap);
                }
                if (this._vipBitmap.parent) 
                {
                    removeChild(this._vipBitmap);
                }
                clearBgColor();
                return;
            }
            _data = arg1;
            var loc1=_data.rank;
            this._rankTxt.text = loc1.toString();
            this._rankTxt.setTextFormat(this._tf);
            if (this._vipBitmap.parent) 
            {
                removeChild(this._vipBitmap);
            }
            var loc2=true;
            var loc3;
            if ((loc3 = _data.vipType) != EVIPType._EVIPTypeWeek) 
            {
                if (loc3 != EVIPType._EVIPTypeMonth) 
                {
                    if (loc3 != EVIPType._EVIPTypeHalfYear) 
                    {
                        loc2 = false;
                    }
                    else 
                    {
                        this._vipBitmap = GlobalClass.getBitmap(ImagesConst.TVip3);
                    }
                }
                else 
                {
                    this._vipBitmap = GlobalClass.getBitmap(ImagesConst.TVip2);
                }
            }
            else 
            {
                this._vipBitmap = GlobalClass.getBitmap(ImagesConst.TVip1);
            }
            if (loc2) 
            {
                this._vipBitmap.x = 25;
                this._vipBitmap.y = 0;
                addChild(this._vipBitmap);
            }
            this._nameTxt.text = _data.entityName;
            this._nameTxt.setTextFormat(this._tf);
            if (arg2 != EToplistType._EToplistTypeArenaMark) 
            {
                if ((loc13 = _data.propertyTwo) != ESex._ESexMan) 
                {
                    if (loc13 == ESex._ESexWoman) 
                    {
                        this._sexTxt.text = Language.getString(32077);
                    }
                }
                else 
                {
                    this._sexTxt.text = Language.getString(32076);
                }
            }
            else 
            {
                this._sexTxt.text = Math.abs(_data.valueTwo) + "";
            }
            this._sexTxt.setTextFormat(this._tf);
            var loc4=_data.propertyThree;
            var loc5=CareerConfig.instance.getInfoByCode(loc4).name;
            this._careerTxt.text = loc5;
            this._careerTxt.setTextFormat(this._tf);
            var loc6=_data.propertyOne;
            var loc7=ColorConfig.instance.getCountryColor(loc6).intColor;
            var loc8=new GTextFormat("", 12, loc7, false, false, false, null, null, flash.text.TextFormatAlign.CENTER);
            var loc9="";
            if (arg2 != EToplistType._EToplistTypeArenaMark) 
            {
                if (arg2 != EToplistType._EToplistTypeWrestleMark) 
                {
                    if (arg2 == EToplistType._EToplistTypeAcupoint || arg2 == EToplistType._EToplistTypeRoot) 
                    {
                        this._campTxt.text = _data.valueTwo + "";
                    }
                    else 
                    {
                        this._campTxt.text = GameDefConfig.instance.getECamp(loc6);
                        this._campTxt.setTextFormat(loc8);
                    }
                }
                else 
                {
                    if (_data.valueThree > 0) 
                    {
                        loc9 = _data.valueThree / 100 + "%";
                    }
                    else 
                    {
                        loc9 = _data.valueThree + "";
                    }
                    this._campTxt.text = loc9;
                }
            }
            else 
            {
                if (_data.valueThree > 0) 
                {
                    loc9 = _data.valueThree + "%";
                }
                else 
                {
                    loc9 = _data.valueThree + "";
                }
                this._campTxt.text = loc9;
            }
            if (_data.ownerName == "") 
            {
                this._guildTxt.text = "--";
            }
            else 
            {
                this._guildTxt.text = _data.ownerName;
            }
            this._guildTxt.setTextFormat(loc8);
            this._attributeTxt.text = _data.valueOne.toString();
            this._attributeTxt.setTextFormat(this._tf);
            if (this._bitmap.parent) 
            {
                removeChild(this._bitmap);
            }
            var loc10=_data.lastRank;
            var loc12=true;
            if (loc10 != 0) 
            {
                if (loc1 > loc10) 
                {
                    this._bitmap = GlobalClass.getBitmap(ImagesConst.RangeDecline);
                    loc11 = (loc1 - loc10).toString();
                }
                else if (loc1 < loc10) 
                {
                    this._bitmap = GlobalClass.getBitmap(ImagesConst.RangeRaise);
                    loc11 = (loc10 - loc1).toString();
                }
                else if (loc1 == loc10) 
                {
                    this._bitmap = GlobalClass.getBitmap(ImagesConst.RangeSame);
                    loc11 = "";
                }
            }
            else 
            {
                loc12 = false;
                loc11 = Language.getString(32078);
            }
            if (loc12) 
            {
                this._bitmap.x = 418;
                this._bitmap.y = 2;
                addChild(this._bitmap);
            }
            this._rangeTxt.text = loc11.toString();
            this._rangeTxt.setTextFormat(this._tf);
            initPlayerMenuInfo();
            return;
        }

        /* internal */ /* var */_tf: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_rankTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_sexTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_careerTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_campTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_guildTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_attributeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_rangeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_bitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_vipBitmap: Object /* flash.display.Bitmap */;
    }
